package com.jvyou.factory;

/**
 * @author 橘柚
 * @version 1.0-SNAPSHOT
 * @Date 2024/7/6 18:44
 * @Description 促销工厂，用于创建不同促销方案的实例
 */
public class PromotionFactory {

    public static Promotion createPromotion(String promotionType) {
        return switch (promotionType) {
            case "cashback" -> new CashbackPromotion(10.0, 100.0);
            case "discount" -> new DiscountPromotion(0.9);
            case "none" -> new NonePromotion();
            default -> throw new IllegalStateException("Unexpected value: " + promotionType);
        };
    }
}
